# 定义一个函数来生成图片
generate_plot <- function(age, weight, plotFilePath) {
    # 打开PNG设备并指定文件路径
    png(plotFilePath, width = 800, height = 600)

    # 绘制月龄和体重的关系图
    plot(age, weight, main="Age vs Weight", xlab="Age (months)", ylab="Weight (kg)")

    # 关闭图形设备
    dev.off()
}

# 调用函数生成图片
generate_plot(age, weight, plotFilePath)